const express = require('express')
const router = express.Router()
const {
  getPropertyList,
  getPropertyDetail,
  uploadImage,
  publishProperty,
  getHotProperty,
  addHotProperty,
  deleteHotProperty,
  propertyTotal,
  hotPropertyTotal,
  deleteProperty,
  searchProperty,
  searchHotProperty
} = require('../../controller/apis/propertyController')

// 导入JWT拦截中间件
const checkTokenMiddleware = require('../../middlewares/checkTokenMiddleware')

// 获取房源列表信息
router.get('/property/list/:id', checkTokenMiddleware, getPropertyList)

// 获取房源详情信息
router.get('/property/detail/:id', checkTokenMiddleware, getPropertyDetail)

// 上传房源图片
router.post('/property/upload', checkTokenMiddleware, uploadImage)

// 发布房源
router.post('/property/publish', checkTokenMiddleware, publishProperty)

// 删除房源
router.delete('/property/:id', checkTokenMiddleware, deleteProperty)

// 获取热门房源信息
router.get('/hot', checkTokenMiddleware, getHotProperty)

// 添加热门房源
router.patch('/property/hot/add/:id', checkTokenMiddleware, addHotProperty)

// 移除热门房源
router.patch('/property/hot/del/:id', checkTokenMiddleware, deleteHotProperty)

// 获取房源总数
router.get('/property/count', checkTokenMiddleware, propertyTotal)

// 获取热门房源总数
router.get('/hot/count', checkTokenMiddleware, hotPropertyTotal)

// 房源列表搜索功能
router.get('/property/search', checkTokenMiddleware, searchProperty)

// 热门房源搜索功能
router.get('/hot/search', checkTokenMiddleware, searchHotProperty)

module.exports = router
